import group from "./group.json"
import type {MockMethod} from "vite-plugin-mock";
import success from "../success.json"
import varlist from "./var.json"
import {findDetailFromList} from "../utils";


const groups = [
    {
        url: "/var/group/list",
        method: "get",
        response: ({body, query}: any) => {
            return group;
        }
    },
    {
        url: "/var/group/detail",
        method: "get",
        response: ({query}: any) => {
            return findDetailFromList(group.data, query.id, "enumGroupId");
        }
    },
    {
        url: "/var/group/save",
        method: "post",
        response: () => {
            return success;
        }
    },
    {
        url: "/var/group/delete",
        method: "delete",
        response: () => {
            return success;
        }
    }
]

const enums = [
    {
        url: "/var/list",
        method: "post",
        response: ({body, query}: any) => {
            return varlist;
        }
    },
    {
        url: "/var/detail",
        method: "get",
        response: ({query}: any) => {
            return findDetailFromList(varlist.data.list, query.varId, "varId");
        }
    },
    {
        url: "/var/save",
        method: "post",
        response: () => {
            return success;
        }
    },
    {
        url: "/var/delete/:id",
        method: "delete",
        response: () => {
            return success;
        }
    }
]

export default [...groups, ...enums] as MockMethod[];
